<?php
$ngay1=$ngay2=$canbo='x';
if($_GET['ngay1']!="")
    $ngay1=$_GET['ngay1'];
if($_GET['ngay2']!="")
    $ngay2=$_GET['ngay2'];
if($_GET['canbo']!="")
    $canbo=$_GET['canbo'];
include('../../configs/connect.php');   
 mysql_query("SET NAMES 'UTF8'");
 
 
$sql="  SELECT DISTINCT	ma_lopmon,ten_donvi 
        FROM 	tbl_lopmon,tbl_donvi 
        WHERE 	ma_cbgv='$canbo' 
        AND	    tbl_lopmon.ma_donvi=tbl_donvi.ma_donvi
        AND 	(ngaybatdau='$ngay1' OR ngaybatdau='$ngay2' OR ngayketthuc='$ngay2' OR ngayketthuc='$ngay1')";
         


$q=mysql_query($sql);
echo mysql_error();
$myarray=array();
$str="";
while($nt=mysql_fetch_array($q)){
$str=$str ."\"$nt[ma_lopmon]\"".","."\"$nt[ten_donvi]\"".",";
}
$str=substr($str,0,(strLen($str)-1)); // Removing the last char , from the string
echo "new Array($str)";

?>